package com.file;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class Test_7 {
    public static void main(String[] args) {
        writer();
    }
    public static void writer(){
        String pathname="D:\\javacode\\javacode\\J2024_11_16\\hello.txt";
        FileReader fileReader=null;
        FileWriter fileWriter=null;
//        char[] buf=new char[16];
        String str="goodafternoon";
        int readlen=0;
        try {
            fileWriter=new FileWriter(pathname);
            fileWriter.write(str);
//            while((readlen=fileReader.read(buf))!=-1){
//                //   System.out.print((char)readlen);
//                System.out.println(new String(buf,0,readlen));
//            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            if(fileWriter!=null){
                try {
                    fileWriter.close();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
        }
    }
}
